﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jzy.Model.CRM;

using Jzy.Core.Common.Web;
using Jzy.Core.Common;
using Frame.Lib.Utilities;
using Frame.Lib.Common;
using Frame.Lib.Web;
using Frame.Lib.Enums;


namespace Jzy.Web.CRM.Customer
{
    public partial class TabItems : System.Web.UI.UserControl
    {
        public string TabIndex
        {
            get;
            set;
        }

        private string CustomerID
        {
            get
            {
                return Request.QueryString["CustomerID"];
            }
        }

        protected string GetClass(object tabIndex)
        {
            if (tabIndex.ToString() == this.TabIndex)
            {
                return "on";
            }
            else
            {
                return "";
            }
        }

        protected string GetUrl(object tabIndex)
        {
            if (tabIndex.ToString() == this.TabIndex)
            {
                return "javascript:;";
            }
            else
            {
                if (string.IsNullOrEmpty(CustomerID))
                {
                    return "javascript:alert(\"请先保存基础信息\")";
                }
                else
                {
                    CustomerTab tab = (CustomerTab)(int)tabIndex;
                    switch (tab)
                    { 
                        case CustomerTab.联系记录:
                            return GlobalVar.WebAppPath + "crm/visit/list.aspx?CustomerID=" + this.CustomerID;
                        case CustomerTab.联系人资料:
                            return GlobalVar.WebAppPath + "crm/contact/list.aspx?CustomerID=" + this.CustomerID;
                        default:
                            return GlobalVar.WebAppPath + "crm/customer/edit.aspx?CustomerID=" + this.CustomerID;
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            CssFileManager.AddCssFile(CssFile.tab1);
           
            BindList();
            
        }
        private void BindList()
        {
            List<EnumInfo> list = ConvertUtil.ConvertEnum(typeof(CustomerTab));
            rpt.DataSource = list;
            rpt.DataBind();
        }
    }
}